<?php
require_once('PHPUnit/Framework.php');
require_once('/home/donald.chen/project/portal_service/trunk/src/pear/common/LuceneXml.class.php');

class LuceneXmlTest extends PHPUnit_Framework_Testcase
{
    private $_lucene_xml;

    public function setUp()
    {
        $this->_lucene_xml = new LuceneXml;
    }

    public function tearDown()
    {
        unset($this->lucene_xml);
    }

    public function testProgrammeAddSuccess()
    {
        $type = 'programme';
        $data = array(
            array('id' => '1', 'name' => 'name1'),
            array('id' => '2', 'name' => 'name2'),
        );
        $act = 'add';
        $file = $this->_lucene_xml->newLuceneXml($type, $data, $act);
        $this->_lucene_xml->addXmlNeedPush($type, $file);
        $this->_lucene_xml->pushXmlToLuceneServer();
    }

    public function testProgrammeEditSuccess()
    {
        $type = 'programme';
        $data = array(
            array('id' => '1', 'name' => 'name1'),
            array('id' => '2', 'name' => 'name2'),
        );
        $act = 'edit';
        $file = $this->_lucene_xml->newLuceneXml($type, $data, $act);
        $this->_lucene_xml->addXmlNeedPush($type, $file);
        $this->_lucene_xml->pushXmlToLuceneServer();
    }

    public function testProgrammeDelSuccess()
    {
        $type = 'programme';
        $data = array(
            array('id' => '1_2'),
            array('id' => '2_3'),
        );
        $act = 'del';
        $file = $this->_lucene_xml->newLuceneXml($type, $data, $act);
        $this->_lucene_xml->addXmlNeedPush($type, $file);
        $this->_lucene_xml->pushXmlToLuceneServer();
    }

}
?>
